<?php
import('ORG.Util.Function');


class RetailAction extends CommonAction {
	
	public function _initialize(){
		parent::_initialize();
		$this->assign('li_selected','retail');
		$this->assign('show_position',0);
		//titile
		$this->assign("global_title",		"渠道服务_音伴尔官网");
	}
	
	public function _empty(){
		$this->redirect("/retail/index");
	}
	
    public function index(){
    	$RetailModel		=	new RetailModel();
    	$province_list		=	$RetailModel->get_province_list();    	
    	$this->assign('province_list',		$province_list);
    	$this->assign("menu_selected",		"qudao");  //显示高亮菜单
		$this->display();
    }
    
    public function get_city_list(){    	
    	$parent_id		=	empty($_REQUEST['region_id']) ? 0 : $_REQUEST['region_id'];
    	$city_list		=	M('Region')->where("parent_id='{$parent_id}'")->select();
    	$RetailModel	=	new RetailModel();
    	$city_list		=	$RetailModel->get_city_list($parent_id);    	
    	
		$this->assign("city_list", $city_list);
		if ($this->isAjax()) {//判断ajax请求
			layout(false);
			$template 	= 	'Retail:l_city_list';
			$html		=	$this->fetch($template);
			$this->ajaxReturn($html);
		}		
    }
    
    public function get_retail_list(){  
		import("@.Org.RetailTool");    	
    	$province		=	empty($_REQUEST['parent_id']) ? 0 : $_REQUEST['parent_id'];
    	$city			=	empty($_REQUEST['region_id']) ? 0 : $_REQUEST['region_id'];    
    	$RetailModel	=	new RetailModel();
    	$retail_list	=	M('Retail')->where(" province='{$province}' and city = '{$city}' ")->select();
    	
		$this->assign("retail_list", 	get_detail_retail($retail_list));
		if ($this->isAjax()) {//判断ajax请求
			layout(false);
			$template 	= 	'Retail:l_retail_list';
			$html		=	$this->fetch($template);
			$this->ajaxReturn($html);
		}	
    }
    
    
}